#Boa:Dialog:Login

import wx
'''import Conexion'''

def create(parent):
    return Login(parent)

[wxID_LOGIN, wxID_LOGINBLOG_CANCEL, wxID_LOGINBLOG_OK, wxID_LOGINPASSWORD, 
 wxID_LOGINSTATICBOX1, wxID_LOGINTXT_PASSWORD, wxID_LOGINTXT_USUARIO, 
 wxID_LOGINUSUARIO, 
] = [wx.NewId() for _init_ctrls in range(8)]

class Login(wx.Dialog):
    def _init_ctrls(self, prnt):
        # generated method, don't edit
        wx.Dialog.__init__(self, id=wxID_LOGIN, name='Login', parent=prnt,
              pos=wx.Point(437, 382), size=wx.Size(352, 277),
              style=wx.CLOSE_BOX | wx.THICK_FRAME | wx.STAY_ON_TOP | wx.STATIC_BORDER | wx.DEFAULT_DIALOG_STYLE,
              title='Logeo')
        self.SetClientSize(wx.Size(336, 239))
        self.SetToolTipString('Logeo')
        self.SetWindowVariant(wx.WINDOW_VARIANT_SMALL)

        self.staticBox1 = wx.StaticBox(id=wxID_LOGINSTATICBOX1, label='',
              name='staticBox1', parent=self, pos=wx.Point(16, 8),
              size=wx.Size(304, 216), style=0)
        self.staticBox1.SetFont(wx.Font(10, wx.SWISS, wx.NORMAL, wx.NORMAL,
              False, 'Tahoma'))

        self.txt_Usuario = wx.TextCtrl(id=wxID_LOGINTXT_USUARIO,
              name='txt_Usuario', parent=self, pos=wx.Point(48, 64),
              size=wx.Size(240, 24), style=0, value='')
        self.txt_Usuario.SetFont(wx.Font(10, wx.SWISS, wx.NORMAL, wx.NORMAL,
              False, 'Tahoma'))
        self.txt_Usuario.SetToolTipString('')
        self.txt_Usuario.SetMaxLength(10)
        self.txt_Usuario.SetHelpText('')

        self.txt_Password = wx.TextCtrl(id=wxID_LOGINTXT_PASSWORD,
              name='txt_Password', parent=self, pos=wx.Point(48, 128),
              size=wx.Size(240, 24), style=wx.TE_PASSWORD, value='')
        self.txt_Password.SetToolTipString('')
        self.txt_Password.SetEditable(True)
        self.txt_Password.SetInsertionPoint(9)
        self.txt_Password.SetMaxLength(6)
        self.txt_Password.SetFont(wx.Font(10, wx.SWISS, wx.NORMAL, wx.NORMAL,
              False, 'Tahoma'))
        self.txt_Password.SetAutoLayout(False)

        self.Usuario = wx.StaticText(id=wxID_LOGINUSUARIO, label='Usuario:',
              name='Usuario', parent=self, pos=wx.Point(48, 40),
              size=wx.Size(48, 16), style=0)
        self.Usuario.SetFont(wx.Font(10, wx.SWISS, wx.NORMAL, wx.NORMAL, False,
              'Tahoma'))
        self.Usuario.SetToolTipString('Usuario')

        self.password = wx.StaticText(id=wxID_LOGINPASSWORD, label='Password:',
              name='password', parent=self, pos=wx.Point(48, 104),
              size=wx.Size(60, 16), style=0)
        self.password.SetFont(wx.Font(10, wx.SWISS, wx.NORMAL, wx.NORMAL, False,
              'Tahoma'))

        self.BLog_Cancel = wx.Button(id=wxID_LOGINBLOG_CANCEL, label='Cancelar',
              name='BLog_Cancel', parent=self, pos=wx.Point(192, 168),
              size=wx.Size(96, 31), style=0)
        self.BLog_Cancel.SetFont(wx.Font(10, wx.SWISS, wx.NORMAL, wx.NORMAL,
              False, 'Tahoma'))
        self.BLog_Cancel.Bind(wx.EVT_BUTTON, self.OnBLog_CancelButton,
              id=wxID_LOGINBLOG_CANCEL)

        self.BLog_OK = wx.Button(id=wxID_LOGINBLOG_OK, label='Aceptar',
              name='BLog_OK', parent=self, pos=wx.Point(48, 168),
              size=wx.Size(96, 31), style=0)
        self.BLog_OK.SetFont(wx.Font(10, wx.SWISS, wx.NORMAL, wx.NORMAL, False,
              'Tahoma'))
        self.BLog_OK.Bind(wx.EVT_BUTTON, self.OnBLog_OKButton,
              id=wxID_LOGINBLOG_OK)

    def __init__(self, parent):
        self._init_ctrls(parent)

    def OnBLog_OKButton(self, event):
        event.Skip()
        self.b_enable=True
        usuario = self.txt_Usuario.GetValue()
        password = self.txt_Password.GetValue()
        IsUserOk(usuario,password)
        self.Close()

    def OnBLog_CancelButton(self, event):
        event.Skip()
        self.b_enable=False
        self.Close()
        
    def IsUserOk(self,usuario,password):
        con=Conexion.Conectar()
        lista=con.obtenerListado()
        return True
    
